<template>
  <div class="home-container">
    <div class="welcome-section">
      <div class="welcome-header">
        <h1>欢迎使用 Electron多功能工具</h1>
        <p class="subtitle">一个现代化的跨平台工具集合</p>
      </div>

      <div class="feature-cards">
        <div class="feature-card" @click="navigateTo('/file')">
          <div class="card-icon file-icon">📁</div>
          <h3>文件管理</h3>
          <p>管理、编辑和分析您的文件</p>
        </div>

        <div class="feature-card" @click="navigateTo('/map')">
          <div class="card-icon map-icon">🗺️</div>
          <h3>地图功能</h3>
          <p>查看地图和位置信息</p>
        </div>

        <div class="feature-card" @click="navigateTo('/settings')">
          <div class="card-icon settings-icon">⚙️</div>
          <h3>应用设置</h3>
          <p>自定义应用程序的行为和外观</p>
        </div>

        <div class="feature-card" @click="navigateTo('/about')">
          <div class="card-icon about-icon">ℹ️</div>
          <h3>关于软件</h3>
          <p>了解软件版本和更新信息</p>
        </div>
      </div>
    </div>

    <div class="system-info">
      <h3>系统信息</h3>
      <div class="info-grid">
        <div class="info-item">
          <span class="info-label">操作系统:</span>
          <span class="info-value">{{ platform }}</span>
        </div>
        <div class="info-item">
          <span class="info-label">Electron版本:</span>
          <span class="info-value" id="electron-version"></span>
        </div>
        <div class="info-item">
          <span class="info-label">Chrome版本:</span>
          <span class="info-value" id="chrome-version"></span>
        </div>
        <div class="info-item">
          <span class="info-label">Node版本:</span>
          <span class="info-value" id="node-version"></span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";

const router = useRouter();
const platform = ref("未知");

// 导航到指定路由
const navigateTo = (path: string) => {
  router.push(path);
};

onMounted(() => {
  // 获取平台信息
  if (window.electronAPI?.platform) {
    platform.value = formatPlatform(window.electronAPI.platform);
  }
});

// 格式化平台名称
const formatPlatform = (platform: string): string => {
  switch (platform) {
    case "win32":
      return "Windows";
    case "darwin":
      return "macOS";
    case "linux":
      return "Linux";
    default:
      return platform;
  }
};
</script>

<style lang="scss" scoped>
.home-container {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.welcome-section {
  margin-bottom: 40px;
}

.welcome-header {
  text-align: center;
  margin-bottom: 40px;

  h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
  }

  .subtitle {
    font-size: 1.2rem;
    color: var(--gray-color);
  }
}

.feature-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.feature-card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  cursor: pointer;

  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  }

  h3 {
    font-size: 1.2rem;
    margin: 15px 0 10px;
    color: var(--dark-color);
  }

  p {
    color: var(--gray-color);
    font-size: 0.9rem;
  }

  .card-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
  }
}

.system-info {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);

  h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--dark-color);
    font-size: 1.2rem;
  }

  .info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
  }

  .info-item {
    display: flex;
    flex-direction: column;

    .info-label {
      font-size: 0.8rem;
      color: var(--gray-color);
      margin-bottom: 5px;
    }

    .info-value {
      font-size: 0.9rem;
      color: var(--dark-color);
      font-weight: 500;
    }
  }
}
</style>
